#ifndef __proto_h__
#define __proto_h__ 


#include "pbc.h"


struct pbc_wmessage;
struct pbc_rmessage;


struct pbc_wmessage *pbc_wmessage_create(struct pbc *p, const char *msgname);
void pbc_wmessage_free(struct pbc_wmessage *m);
void pbc_wmessage_buffer(struct pbc_wmessage *m, struct chumk *ck);
struct pbc_wmessage *pbc_wmessage_message(struct pbc_wmessage *p, const char *msgname);


int pbc_encode_int32(struct pbc_wmessage *wmsg, const char *fieldname, int value);
int pbc_encode_int64(struct pbc_wmessage *wmsg, const char *fieldname, int64_t value);
int pbc_encode_float(struct pbc_wmessage *wmsg, const char *fieldname, float value);
int pbc_encode_string(struct pbc_wmessage *wmsg, const char *fieldname, const char *value);



struct pbc_rmessage *pbc_rmessage_create(struct pbc *p, const char *msgname, struct chumk *ck);
void pbc_rmessage_free(struct pbc_rmessage *m);
struct pbc_rmessage *pbc_rmessage_message(struct pbc_rmessage *p, const char *msgname, int idx);


int pbc_decode_int32(struct pbc_rmessage *rmsg, const char *fieldname, int idx, int def);
int64_t pbc_decode_int64(struct pbc_rmessage *rmsg, const char *fieldname, int idx, int64_t def);
float pbc_decode_float(struct pbc_rmessage *rmsg, const char *fieldname, int idx, float def);
const char *pbc_decode_string(struct pbc_rmessage *rmsg, const char *fieldname, int idx, const char *def);

int pbc_rmessage_size(struct pbc_rmessage *rmsg, const char *fieldname);


#endif

